package com.flong.desgin.patterns.inversion;

import lombok.var;

/**
 * @Author:liangjl
 * @Date: 2020/3/7-18:50
 * @Eamil:jilongliang@sina.com
 * @Description: 依赖倒置原则
 */
public class DependecyInversion {
    public static void main(String[] args) {
        var p = new Person();
        p.receive(new Email());
        p.receive(new Wechat());
    }
}

interface IReceiver {
    String getInfo();
}

class Wechat implements IReceiver {

    @Override
    public String getInfo() {
        return "this is Wechat";
    }
}
class Email implements IReceiver {

    @Override
    public String getInfo() {
        return "this is email";
    }
}

//完成Person接收消息的功能
class Person {

    public void receive(IReceiver rReceiver) {
        System.out.println(rReceiver.getInfo());
    }
}